package org.nicocube.airain.gwt.client.ui;

import org.nicocube.airain.domain.client.character.AttributeIdentifier;
import org.nicocube.airain.domain.client.character.SkillIdentifier;
import org.nicocube.airain.gwt.client.AirainWeb;
import org.nicocube.airain.gwt.client.ui.item.ItemValued;
import org.nicocube.airain.gwt.client.ui.item.TableHeader;
import org.nicocube.airain.gwt.client.ui.item.TableOfItem;

import com.google.gwt.user.client.ui.HorizontalPanel;
import com.google.gwt.user.client.ui.Label;
import com.google.gwt.user.client.ui.Panel;
import com.google.gwt.user.client.ui.Widget;

public class AttrAndSkillPanel extends AirainPanel {

	HorizontalPanel myPanel;
	
	public Widget getLabel() {
		return new Label("Attribute and Skills",false);
	}
	
	public AttrAndSkillPanel(AirainWeb aw) {
		super(aw);
		myPanel = new HorizontalPanel();
		
		TableOfItem<ItemValued> attributeTable = new TableOfItem<ItemValued>(
				new TableHeader()
				.addCols("Attribute")
				.addCols("Level")
		);

		for (AttributeIdentifier attr : AttributeIdentifier.values()) {
			attributeTable.addRows(
					new ItemValued()
					.setIdent(attr.toString())
					.addValue(getAW().getGc().getAttributeLevel(attr).toString())
			);
		}

		myPanel.add(attributeTable.render());

		TableOfItem<ItemValued> skillTable = new TableOfItem<ItemValued>(
				new TableHeader()
				.addCols("Skill")
				.addCols("Expertise")
		);

		for (SkillIdentifier skill : SkillIdentifier.values()) {
			skillTable.addRows(
					new ItemValued()
					.setIdent(skill.toString())
					.addValue(getAW().getGc().getSkillExpertise(skill).toString())
			);
		}

		myPanel.add(skillTable.render());

	}

	@Override
	public Panel getPanel() {
		return myPanel;
	}
}
